<extend name="./public/frame.html"/>
<block name="content">
    <style>
        .layui-form-label{width: 10%;}
        .layui-input-block{margin-left: 12%;}
    </style>
    <form class="layui-form layui-form-pane1" action="" method="post" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">所属城市</label>
            <div class="layui-input-block">
                <div class="layui-row" style="float:left;width: 200px;">
                    <div class="layui-col-xs3">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <div class="layui-input-inline" style="width: 200px;margin-right: 5px;">
                                    <select name="province_id" id="province_id" lay-verify="required" lay-filter="province">
                                        <option value="">请选择省份</option>
                                        <?php foreach($provinceList as $key=>$value):?>
                                        <option value="<?php echo $value['region_id'];?>"><?php echo $value['region_name'];?></option>
                                        <?php endforeach;?>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row" style="float:left;width: 200px;margin-left: 5px;">
                    <div class="layui-col-xs3">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <div class="layui-input-inline" style="width: 200px;margin-right: 5px;">
                                    <select name="city_id" id="city_id" lay-verify="required" lay-filter="city">
                                        <option value="">请选择城市</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">车辆种类名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" placeholder="车辆种类名称"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">标识符</label>
            <div class="layui-input-block">
                <input type="text" name="nid" lay-verify="required" placeholder="标识符"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="is_open" value="1" title="显示" checked>
                <input type="radio" name="is_open" value="0" title="隐藏">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" lay-verify="required" placeholder="排序"
                       autocomplete="off" class="layui-input" value="1">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['form'], function () {
            form = layui.form;
            form.on('select(province)', function(data){
                $("#city_id").empty();
                $("#city_id").append('<option value=>请选择城市</option>');
                var province_id = data.value;
                $.ajax({
                    url:'{:url("/admin/Franchisee/cityList")}',
                    async:true,
                    //dataType:'json',
                    type:'post',
                    data:{'province_id':province_id},
                    success:function(res){
                        $("#city_id").append(res);
                        form.render('select');
                    },
                    error:function(e){
                        layer.msg('请求错误');return false;
                    }
                })
            });
            //监听提交
            form.on('submit(submit)', function (data) {

            });

        });
    </script>
</block>
